package cn.sypt.yuhao.servlet;

import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import cn.sypt.yuhao.dao.VideoDao;
import cn.sypt.yuhao.domain.Words;

public class WordsFilter implements Filter{
	private List<Words> words ;
	@Override
	public void destroy() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		chain.doFilter(request, response);
		
		
	}
	public static String replace(String resourse, String words) {
       
		boolean flag=resourse.contains(words);
		if(flag){
			resourse=resourse.replaceAll(words, "***");
		}
        return resourse;
    }
	@Override
	public void init(FilterConfig arg0) throws ServletException {
		VideoDao vd=new VideoDao();
		 words=vd.findWords();
		
	}

}
